import Vue from 'vue'
import VueRouter from 'vue-router'
import process from "shelljs";
import Home from "../views/Home";
import Index from '../views/Index'
import User from '../views/sys/User'
import Role from '../views/sys/Role'
import Menu from '../views/sys/Menu'
import axios from "../axios";


Vue.use(VueRouter)
const routes = [

  {
    path: "/",
    name: 'Home',
    component: Home,
    children:[
      {
        path: "/index",
        name: 'Index',
        component: () => import('../views/Index')
      },
      {
        path: "/userCenter",
        name: 'UserCenter',
        component: () => import('../views/UserCenter')
      },
      {
        path: "/sys/users",
        name: 'SysUser',
        component: User
      },
      {
        path: "/sys/roles",
        name: 'SysRole',
        component: Role
      },
      {
        path: "/sys/menus",
        name: 'SysMenu',
        component: Menu
      },
    ]
  },



  {
    path: "/login",
    name: 'Login',
    component: () => import('../views/Login')
  },


]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {

  axios.get("/sys/menu/nav",{
    headers:{
      Authorization:localStorage.getItem("token")
    }
  }).then(res=>{

    //拿到menuList


    //拿到用户权限


  })

  next()
})

export default router
